<?php

/**
 * Event Type 	View
 * @author 		TAMDV
 * @date		2008 07 21 (yyyy MM dd)
 * @package    	Joomus.JBS
 * @subpackage 	Components
 * @link 		http://localhost/jbschedule/administrator/index.php?option=com_jbschedule
 * @license		GNU/GPL
 */

// no direct access
//defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.view');

/**
 * Event Type View
 *
 * @package    Joomus.JBS
 * @subpackage Components
 */
class JBSViewEventTypes extends JView {
	/**
	 * display method of Event Type view
	 * @return void
	 **/
	function display($tpl = null) {
		$task = JRequest :: getVar('task');

		switch ($task) {
			case 'edit':
			case 'add' :
				//get the assetgroups
				$eventtypes = & $this->get('DataOne');
				$isNew = ($eventtypes->id < 1);

				$text = $isNew ? JText :: _('NEW') : JText :: _('EDIT');
				JToolBarHelper :: title(JText :: _('PROJECT NAME') . ' - ' . JText :: _('EVENT TYPES') . ': <small><small>[ ' . $text . ' ]</small></small>', 'jbschedule');
				JToolBarHelper :: save();
				if ($isNew) {
					JToolBarHelper :: cancel();
				} else {
					// for existing items the button is renamed `close`
					JToolBarHelper :: cancel('CANCEL', 'CLOSE');
				}
				$this->assignRef('eventtypes', $eventtypes);
				break;

			default :
				global $mainframe, $option;
				//initialise variables
				//$document	= & JFactory::getDocument();
				$db			= & JFactory::getDBO();
				//$user 		= & JFactory::getUser();
				
				
				
				//get vars
				$filter_order		= $mainframe->getUserStateFromRequest( $option.'.eventtypes.filter_order', 'filter_order', 	'title', 'cmd' );				
				$filter_order_Dir	= $mainframe->getUserStateFromRequest( $option.'.eventtypes.filter_order_Dir', 'filter_order_Dir', '', 'word' );
				$search 			= $mainframe->getUserStateFromRequest( $option.'.eventtypes.search', 'search', '', 'string' );
				$search 			= $db->getEscaped( trim(JString::strtolower( $search ) ) );
				$template			= $mainframe->getTemplate();
				
				JToolBarHelper :: title(JText :: _('PROJECT NAME') . ' - ' . JText :: _('EVENT TYPES MANAGER'), 'jbschedule');
				JToolBarHelper :: deleteList(JText :: _('ARE YOU SURE')); //param: 1: message 2: task to do 3: Label of the button
				JToolBarHelper :: editListX();
				JToolBarHelper :: addNewX();

				// Get data from the model
				$items      = & $this->get( 'Data');
				//$total    = & $this->get( 'Total');
				$pageNav 	= & $this->get( 'Pagination' );				
				
				// table ordering
				$lists['order_Dir'] = $filter_order_Dir;
				$lists['order'] = $filter_order;
		
				// search filter
				$lists['search']= $search;
				
				$this->assignRef('items'		, $items);				
				$this->assignRef('lists'      	, $lists);
				$this->assignRef('pageNav' 		, $pageNav);
				$this->assignRef('template'		, $template);
				
				
		}
		parent :: display($tpl);
	}
}